/**
 * 
 */
package co.edu.udem.service.place;

import java.util.ArrayList;
import java.util.List;

import co.edu.udem.domain.Place;
import co.edu.udem.service.GenericDTO;

/**
 * @since 29/07/2012
 */
public class PlaceDTO extends GenericDTO {

	private String placeCode;

	private String placeName;

	private String placeDescription;

	private String room;

	private String block;

	private int placeType;

	private String placeTypeDescription;

	private Double longitude;

	private Double latitude;

	/*
	 * (non-Javadoc)
	 * 
	 * @see co.edu.udem.service.GenericDTO#writeValuesToStringBuilder(java.lang.
	 * StringBuilder)
	 */
	@Override
	public void writeValuesToStringBuilder(StringBuilder stringBuilder) {
		stringBuilder.append(this.getPlaceCode() == null ? " NULL, "
				: appendValueFormat(this.getPlaceCode(), true));
		stringBuilder.append(this.getPlaceName() == null ? " NULL, "
				: appendValueFormat(this.getPlaceName(), true));
		stringBuilder.append(this.getPlaceDescription() == null ? " NULL, "
				: appendValueFormat(this.getPlaceDescription(), true));
		stringBuilder.append(this.getRoom() == null ? " NULL, "
				: appendValueFormat(this.getRoom(), true));
		stringBuilder.append(this.getBlock() == null ? " NULL, "
				: appendValueFormat(this.getBlock(), true));
		stringBuilder.append(this.getPlaceType() + ", ");
		stringBuilder.append(this.getPlaceTypeDescription() == null ? " NULL,"
				: appendValueFormat(this.getPlaceTypeDescription(), true));
		stringBuilder.append(this.getLongitude() + ", ");
		stringBuilder.append(this.getLatitude());
	}

	public static List<GenericDTO> populateDTOList(List<Place> placeList) {
		List<GenericDTO> placeDTOList = new ArrayList<GenericDTO>();

		if (placeList != null && !placeList.isEmpty()) {
			PlaceDTO placeDTO;
			for (Place place : placeList) {
				placeDTO = new PlaceDTO();
				placeDTO.setBlock(place.getBlock());
				placeDTO.setLatitude(place.getLatitude());
				placeDTO.setLongitude(place.getLongitude());
				placeDTO.setPlaceCode(place.getPlaceCode());
				placeDTO.setPlaceDescription(place.getPlaceDescription());
				placeDTO.setPlaceName(place.getPlaceName());
				placeDTO.setPlaceType(place.getPlaceType());
				placeDTO.setPlaceTypeDescription(place
						.getPlaceTypeDescription());
				placeDTO.setRoom(place.getRoom());
				placeDTOList.add(placeDTO);
			}
		}
		return placeDTOList;
	}

	public String getPlaceCode() {
		return placeCode;
	}

	public void setPlaceCode(String placeCode) {
		this.placeCode = placeCode;
	}

	public String getPlaceName() {
		return placeName;
	}

	public void setPlaceName(String placeName) {
		this.placeName = placeName;
	}

	public String getPlaceDescription() {
		return placeDescription;
	}

	public void setPlaceDescription(String placeDescription) {
		this.placeDescription = placeDescription;
	}

	public String getRoom() {
		return room;
	}

	public void setRoom(String room) {
		this.room = room;
	}

	public String getBlock() {
		return block;
	}

	public void setBlock(String block) {
		this.block = block;
	}

	public int getPlaceType() {
		return placeType;
	}

	public void setPlaceType(int placeType) {
		this.placeType = placeType;
	}

	public String getPlaceTypeDescription() {
		return placeTypeDescription;
	}

	public void setPlaceTypeDescription(String placeTypeDescription) {
		this.placeTypeDescription = placeTypeDescription;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

}
